package com.test10;

import org.junit.Test;

import java.util.Random;

@FunctionalInterface
interface IFunction {
    public long round(double value);
}

@FunctionalInterface
interface IFunction2 {
    public int nextInt(int bound);
}

@FunctionalInterface
interface IFunction3 {
    public int indexOf(String str, String target);
}

@FunctionalInterface
interface IFunction4 {
    public StringBuilder getStringBuilder(CharSequence sequence);
}

public class MyTest_02 {

    @Test
    public void test1() {
        IFunction function = Math :: round;
        System.out.println(function.round(34.55));
    }

    @Test
    public void test2() {
        Random random = new Random();
        IFunction2 function = random :: nextInt;
        System.out.println(function.nextInt(100));
    }

    @Test
    public void test3() {
        IFunction3 function = String :: indexOf;
        System.out.println(function.indexOf("www.baidu.com", "baidu"));
    }

    @Test
    public void test4() {
        IFunction4 function = StringBuilder :: new;
        StringBuilder builder = function.getStringBuilder("阿里锅巴");
        System.out.println(builder.length());
    }
}
